﻿using CommunityToolkit.Mvvm.Messaging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WpfDemo.ViewModel;

namespace WpfDemo.View
{
    /// <summary>
    /// LoginView.xaml 的交互逻辑
    /// </summary>
    public partial class LoginView : Window
    {
        public LoginView(LoginViewModel loginViewModel)
        {
            InitializeComponent();
            this.DataContext = loginViewModel;         
            WeakReferenceMessenger.Default.Register<string, string>(this, "UserNameErrorToken", UserNameErrorToken);
         
        }

        private void UserNameErrorToken(object recipient, string message)
        {
            this.UserNameStr.IsError = true;
            this.UserNameStr.ErrorStr = message;       
        }

     
        private void LoginWindow_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                DragMove();
            }
        }
        protected void CloseWin_click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
